package 读电话号码;

import java.util.Scanner;

public class Main {
    static String[] num = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"};
    static String[] cnt = {"", "", "double", "triple", "quadruple", "quintuple",
            "sextuple", "septuple", "octuple", "nonuple", "decuple"};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int cases = 1; cases <= T; cases++) {
            String number = in.next();
            String[] a = in.next().split("-");
            int[] format = new int[a.length];
            for (int i = 0; i < a.length; i++) {
                format[i] = Integer.parseInt(a[i]);
            }
            int start = 0;
            System.out.printf("Case #%d:  ", cases);
            for (int i : format) {
                print(number.substring(start, start + i));
                start += i;
            }
            System.out.println();
        }
    }

    private static void print(String str) {
        for (int i = 0; i < str.length(); i++) {
            int j = i + 1;
            while (j < str.length() && str.charAt(i) == str.charAt(j)) {
                j++;
            }
            int len = j - i;
            if (len == 1) {
                System.out.print(num[str.charAt(i) - '0'] + " ");
            } else if (len >= 2 && len <= 10) {
                System.out.print(cnt[len] + " " + num[str.charAt(i) - '0'] + " ");
            } else {
                for (int k = 0; k < len; k++) {
                    System.out.print(num[str.charAt(i) - '0'] + " ");
                }
            }
            i = j - 1;
        }
    }
}
